<template>
  <div>
      <table>
          <tr>
              <th>ID</th>
              <th>资源名称</th>
              <th>资源路径</th>
              <th>资源分类</th>
          </tr>
          <tr v-for="i in resourcelist" :key="i.id">
              <td>{{i.id}}</td>
              <td>{{i.name}}</td>
              <td>{{i.url}}</td>
              <td>{{i.pid}}</td>
          </tr>
      </table>
        <van-field v-model="this.from.name" label="资源名称" />
        <van-field v-model="this.from.url" label="资源路径" />
        <van-field v-model="this.from.type" label="类资源型" />
        <van-field v-model="this.from.pid" label="资源分类"  />

      <van-button @click="addresource">
          添加
      </van-button>
  </div>
</template>

<script>
import myaxios from '../components/http/axios'
export default {
    data(){
        return{
            resourcelist:[],
            from:{
                name:"",
                url:"",
                type:"",
                pid:""
            }
        }
    },
    methods:{
        getresource(){
            myaxios('getresource','get').then(res=>{
                this.resourcelist = res.list
            })
        },
        addresource(){
            myaxios('addresource','post',this.from).then(res=>{
                console.log(res);
                alert('添加成功')
            })
        }
    },
    mounted(){
        this.getresource()
    }

}
</script>

<style>

</style>